package com.mvvm.store.ui.stockup.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.lihang.nbadapter.BaseAdapter;
import com.mvvm.store.R;
import com.mvvm.store.base.BaseViewHolder;
import com.mvvm.store.bean.basebean.DeliveryInfoBean;
import com.mvvm.store.bean.basebean.StockUpInfoBean;
import com.mvvm.store.databinding.ItemDeliveryInfoBinding;
import com.mvvm.store.databinding.ItemStockInfoBinding;

public class StockInfoAdapter extends BaseAdapter<StockUpInfoBean> {

    @Override
    public RecyclerView.ViewHolder getViewHolder(ViewGroup viewGroup, int viewType) {
        ItemStockInfoBinding itemStockInfoBinding= DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), R.layout.item_stock_info, viewGroup, false);
        return new BaseViewHolder(itemStockInfoBinding);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
        BaseViewHolder baseViewHolder = (BaseViewHolder) viewHolder;
        ItemStockInfoBinding itemStockInfoBinding=(ItemStockInfoBinding) baseViewHolder.binding;
        StockUpInfoBean stockUpInfoBean=dataList.get(i);

        itemStockInfoBinding.tvOddNumber.setText(stockUpInfoBean.getOddNumber()+"");

        itemStockInfoBinding.tvMaterialSnpNumber.setText(stockUpInfoBean.getSumNumber()+"");

        itemStockInfoBinding.tvSumNumber.setText(stockUpInfoBean.getRealToNumber()+"");

        itemStockInfoBinding.tvPackNumber.setText(stockUpInfoBean.getPackNumber()+"");

        itemStockInfoBinding.tvLableNumber.setText(stockUpInfoBean.getRealToPack()+"");

        if(stockUpInfoBean.getSumNumber()==stockUpInfoBean.getRealToNumber()){
            itemStockInfoBinding.ivFinishOrder.setVisibility(View.VISIBLE);
        }else {
            itemStockInfoBinding.ivFinishOrder.setVisibility(View.GONE);
        }

    }
}
